<html>  
  <head>  
        <meta charset="utf-8">  
        <title>5.1.3 量子和分位比例尺</title>  
  </head> 
<body>

<script src="../../d3/d3.min.js" charset="utf-8"></script> 
<script>  



var quantize = d3.scale.quantize()
				.domain([50,0])
				.range(["#888","#666","#444","#222","#000"]);
				
var r = [45,35,25,15,5];

var svg = d3.select("body").append("svg")
				.attr("width",400)
				.attr("height",400);

svg.selectAll("circle")
	.data(r)
	.enter()
	.append("circle")
	.attr("cx",function(d,i){ return 50 + i * 30; })
	.attr("cy",50)
	.attr("r",function(d){ return d; })
	.attr("fill",function(d){ return quantize(d); });


/*
var quantize = d3.scale.quantize().domain([0,2,8,10]).range([1,100]),
    quantile = d3.scale.quantile().domain([0,2,5,10]).range([1,100]);

console.log( quantize(4.99) );
console.log( quantize(5) );
console.log( quantile(2.99) );
console.log( quantile(3) );
console.log( quantile.quantiles() );*/
</script> 

</body>

</html>